package com.xiao.dynamic_rule.utils;

import com.xiao.dynamic_rule.pojo.RuleParam;
import com.xiao.dynamic_rule.pojo.RuleParamAtomic;

import java.util.ArrayList;
import java.util.HashMap;

public class RuleSimulator {
    public static RuleParam getRuleParam() {

        RuleParam ruleParam = new RuleParam();
        ruleParam.setRuleId("test_rule_1");

        // 构造触发条件
        RuleParamAtomic trigger = new RuleParamAtomic();
        trigger.setEventId("E");
        ruleParam.setTriggerParam(trigger);

        // 构造画像条件
        HashMap<String, String> userProfileParams = new HashMap<>();
        userProfileParams.put("profileKey12", "profileValue92");
        userProfileParams.put("profileKey22", "profileValue3");
        ruleParam.setUserProfileParams(userProfileParams);

        // 构造行为次数条件
        RuleParamAtomic count1 = new RuleParamAtomic();
        count1.setEventId("B");
        HashMap<String, String> paramProps1 = new HashMap<>();
        paramProps1.put("p1", "v1");
        count1.setProperties(paramProps1);
        count1.setRangeStart(0);
        count1.setRangeEnd(Long.MAX_VALUE);
        count1.setCnts(2);

        RuleParamAtomic count2 = new RuleParamAtomic();
        count2.setEventId("D");
        HashMap<String, String> paramProps2 = new HashMap<>();
        paramProps2.put("p2", "v3");
        count2.setProperties(paramProps2);
        count2.setRangeStart(0);
        count2.setRangeEnd(Long.MAX_VALUE);
        count2.setCnts(2);

        ArrayList<RuleParamAtomic> ruleCountParams = new ArrayList<>();
        ruleCountParams.add(count1);
        ruleCountParams.add(count2);
        ruleParam.setUserActionCountParams(ruleCountParams);

        // 构造行为次序条件
        RuleParamAtomic param1 = new RuleParamAtomic();
        param1.setEventId("A");
        HashMap<String, String> seqProps1 = new HashMap<>();
        seqProps1.put("p1", "v1");
        param1.setProperties(seqProps1);

        RuleParamAtomic param2 = new RuleParamAtomic();
        param2.setEventId("C");
        HashMap<String, String> seqProps2 = new HashMap<>();
        seqProps2.put("p2", "v3");
        param2.setProperties(seqProps2);

        ArrayList<RuleParamAtomic> ruleSeqParams = new ArrayList<>();
        ruleSeqParams.add(param1);
        ruleSeqParams.add(param2);
        ruleParam.setUserActionSequenceParams(ruleSeqParams);


        return ruleParam;
    }
}
